package com.ruoyi.graduate.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.graduate.domain.entity.MsMessageBoard;
import com.ruoyi.graduate.domain.param.MsMessageBoardAddParam;
import com.ruoyi.graduate.domain.param.MsMessageBoardPageParam;
import com.ruoyi.graduate.domain.param.MsMessageBoardUpdataParam;
import com.ruoyi.graduate.domain.param.MsMessageBoardUserPageParam;
import com.ruoyi.graduate.service.IMsMessageBoardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 留言信息控制接口
 */
@RestController
@RequestMapping("/api/message")
@Api(tags = "留言信息控制接口")
public class MsMessageBoardController extends BaseController {

    @Autowired
    private IMsMessageBoardService msMessageBoardService;


    @ApiOperation("留言分页查询")
    @GetMapping
    public TableDataInfo pageList(MsMessageBoardPageParam param){
        PageInfo pageInfo = msMessageBoardService.pageList(param);

        return getDataTable(pageInfo.getList(),pageInfo.getTotal());
    }


    @ApiOperation("留言详情")
    @GetMapping("{id}")
    public AjaxResult detail(@PathVariable("id") Integer id) {

        return AjaxResult.success(msMessageBoardService.detail(id));
    }


    @ApiOperation("留言新增")
    @PostMapping
    public AjaxResult add(@RequestBody MsMessageBoardAddParam param) {

        return msMessageBoardService.add(param);
    }


    @ApiOperation("留言修改")
    @PutMapping
    public AjaxResult updata(@RequestBody MsMessageBoardUpdataParam param) {
        return msMessageBoardService.updata(param);
    }


    @ApiOperation("留言删除")
    @DeleteMapping("{id}")
    public AjaxResult delete(@PathVariable("id") Integer id) {



        return msMessageBoardService.delete(id);
    }


    @ApiOperation("用户端留言查询列表")
    @GetMapping("/userPageList")
    public AjaxResult userPageList(Integer postId) {

        return AjaxResult.success(msMessageBoardService.userPageList(postId));
    }
}
